package com.matt.foundation.vo.course;

import com.matt.foundation.DO.ChildrenCourseItemDO;
import com.matt.commons.dto.sso.StaffDTO;
import com.matt.foundation.utils.DateUtil;
import lombok.Data;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/9/19
 * *******************************
 */
@Data
public class AreaCourseListVo {

    private String planId;

    private String courseDate;

    private String beginTime;

    private String endTime;

    private String title;

    private Integer prepareStatus;

    private String teachingAreaName;

    private String teacherName;

    private List<String> childrenNames;

    public static AreaCourseListVo of(Object[] plans, List<ChildrenCourseItemDO> itemList, StaffDTO staff) {
        AreaCourseListVo vo = new AreaCourseListVo();
        vo.setPlanId(plans[0] == null ? "" : plans[0].toString());
        vo.setCourseDate(plans[1] == null ? "" : DateUtil.millisToDateTime(((Date) plans[1]).getTime(), "yyyy-MM-dd"));
        vo.setBeginTime(plans[2] == null ? "" : DateUtil.millisToDateTime(((Date) plans[2]).getTime(), "HH:mm"));
        vo.setEndTime(plans[3] == null ? "" : DateUtil.millisToDateTime(((Date) plans[3]).getTime(), "HH:mm"));
        vo.setTitle(plans[4] == null ? "" : plans[4].toString());
        vo.setPrepareStatus(plans[5] == null ? 0 : Integer.valueOf(plans[5].toString()));
        vo.setTeachingAreaName(plans[6] == null ? "" : plans[6].toString());
        vo.setTeacherName(staff.getRealName());
        vo.setChildrenNames(itemList.stream().map(o->o.getName()).collect(Collectors.toList()));
        return vo;
    }
}
